﻿// See https://aka.ms/new-console-template for more information
using HostingDemo;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Console.WriteLine("Hello, World!");

var collector = new FakeMetricsCollector();
new HostBuilder()
    .ConfigureAppConfiguration(builder =>
    {
        builder.AddJsonFile("appsettings.json");
    })
    .ConfigureServices((ctx, service) =>
    {
                    //service.AddHostedService<PerformanceMetricsCollector>();
                    //service.AddSingleton<IHostedService, PerformanceMetricsCollector>();
                    service.AddSingleton<IProcessorMetricsCollector>(collector);
        service.AddSingleton<IMemoryMetricsCollector>(collector);
        service.AddSingleton<INetworkMetricsCollector>(collector);

        service.AddSingleton<IMetricsDeliver, FakeMetricsDeliver>();
        service.AddHostedService<PerformanceMetricsCollector2>();

        service.AddOptions().Configure<MetricsCollectorOption>(ctx.Configuration.GetSection("MetricsCollector"));
    })
    .Build().Run();
